<?php
// 本类由系统自动生成，仅供测试用途
class IndexAction extends Action {
    public function index(){
		$this->indexpic();
		$this->dtjs();
		$this->index_dtjs_img();
		$this->index_xxgs();
		$this->index_xxgs_img();
		$this->index_ywjs_img();
		$this->index_ywjs();
        $this->display();
    }
	public function gaikuang(){
		$this->indexpic();
		$this->dtjs();
		$this->display();
	}
	public function lamp(){
		$this->indexpic();
		$this->zmdt();
		$this->display();
	}
	public function rule(){
		$this->indexpic();
		$this->gzzd();
		$this->display();
	}
	public function team(){
		$this->indexpic();
		$this->jstd();
		$this->display();
	}

	//--以下部分控制首页的显示

	//显示首页顶图
	public function indexpic(){
		$article=M('article');
		$cond['type']='首页顶图';
		$list=$article->where($cond)->order('istop DESC')->limit('0,1')->select();
		//dump($list);
		$this->assign('nlist',$list[0]);
	}
	//显示大厅介绍的图片
	private function index_dtjs_img(){
		$article=M('article');
		$cond['isindex']='1';
		$cond['type']='首页图片切换';
		$dtjs_img=$article->where($cond)->order('istop DESC')->limit('0,4')->select();
		//dump($dtjs_img);
		$this->assign('list',$dtjs_img);
	}
	//显示大厅介绍的文字
	private function dtjs(){
		$article=M('article');
		$cond['isindex']='1';
		$cond['type']='大厅简介';
		$index=$article->where($cond)->select();
		$dtjs=$index[0]['content'];
		//dump($dtjs);
		$this->assign('dtjs',$dtjs);
	}
	//显示信息公示的图片
	private function index_xxgs_img(){
		$article=M('article');
		$cond['isindex']='1';
		$cond['type']='信息公示图片';
		$index=$article->where($cond)->order('istop DESC')->limit('0,1')->select();
		$xxgs_img=$index[0]['image'];
		$this->assign('xxgs_img',$xxgs_img);
	}
	//显示信息公示的文字
	private function index_xxgs(){
		$article=M('article');
		$cond['image']=array('eq','');
		$cond['isindex']=1;
		$cond['type']=array('neq','大厅简介');
		$xxgs=$article->where($cond)->select();
		$this->assign('list1',$xxgs);
	}
	//显示业务介绍的图片
	private function index_ywjs_img(){
		$article=M('article');
		$cond['type']='业务介绍图片';
		$ywjs_img=$article->where($cond)->order('istop DESC')->limit('0,1')->select();
		$this->assign('ywjs_img',$ywjs_img[0]['image']);
	}
	//显示业务介绍的文字
	private function index_ywjs(){
		$article=M('article');
		$cond['type']='业务介绍';
		$ywjs=$article->where($cond)->order('istop DESC')->limit('0,3')->select();
		$this->assign('list2',$ywjs);
	}

	//--以下部分为工作制度
	private function gzzd(){
		$article=M('article');
		$cond['type']='工作制度';
		$index=$article->where($cond)->select();
		$gzzd=$index[0]['content'];
		$this->assign('gzzd',$gzzd);
	}
	//--以下部分为建设团队
	private function jstd(){
		$article=M('article');
		$cond['type']='建设团队';
		$index=$article->where($cond)->select();
		$jstd=$index[0]['content'];
		$this->assign('jstd',$jstd);
	}
	//--以下部分为最美大厅
	private function zmdt(){
		$article=M('article');
		import("ORG.Util.Page");//导入分页类
		$cond['type']='最美大厅';
		$index=$article->where($cond)->count();
		$Page = new Page($index,4);//实例化分页类传入总记录数和每页显示的记录数
		$show = $Page->show();//分页显示输出
		//进行分页数据查询注意limit方法的参数要使用Page类的属性
		$list = $article->where($cond)->order('istop DESC')->limit($Page->firstRow.','.$Page->listRows)->select();

		for($i=0;$i<count($list);$i++){
			$list[$i]['pubtime'] = 	date("Y-m-d H:i",$list[$i]['pubtime']);
		}
		$this->assign('list',$list);
		$this->assign('page',$show);//赋值分页输出
	}
}